﻿using MySql.Data.MySqlClient;
using NB.MGJ.Common.Utility;
using NB.MGJ.Model;
using NB.MGJ.Model.AntiFleeingEntity;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NB.MGJ.Service
{
    public partial class FleeGoodsService
    {

        /// <summary>
        ///             0 表是没找到数据或表          1 代表有数据但不是本机构生的码          2 代表成功
        /// </summary>
        /// <param name="code"></param>
        /// <param name="EnterpriseId"></param>
        /// <returns></returns>

        public int CheckTable(string code, int EnterpriseId)
        {
            try
            {
                string tabSuffix = "nbcodemain.AntiFake_Digitcode" + code.Substring(0, AppConst.SubStrLen);//获取到表名
                string sql = @"select * from {0}  where Wl_Code='{1}' limit 1";
                sql = string.Format(sql, tabSuffix, code);
                AntiFake_Digitcode result = _baseRepository.ExecuteText<AntiFake_Digitcode>(sql);
                if (result == null)
                {
                    return 0;
                }
                else
                {
                    if (EnterpriseId != 1)
                    {
                        if (result.EnterpriseId != EnterpriseId) return 1;
                        else return 2;
                    }
                    else
                    {
                        return 2;
                    }

                }
            }
            catch (Exception)
            {

                return 0;
            }
        }

        #region 产品入库
        /// <summary>
        /// 导出
        /// </summary>
        /// <param name="psearch"></param>
        /// <returns></returns>
        public IEnumerable<V_IOWarehouse> GetAllFleeGood(string Ssearch)
        {
            var resule = @"SELECT* FROM  AntiFleeing_IOWarehouse LEFT OUTER JOIN
                     Organization_Enterprise ON AntiFleeing_IOWarehouse.EnterpriseID =Organization_Enterprise.ID LEFT OUTER JOIN
                     Product_Product ON AntiFleeing_IOWarehouse.ProductID =Product_Product.ID LEFT OUTER JOIN
                      AntiFleeing_Warehouse ON AntiFleeing_IOWarehouse.WarehouseId =AntiFleeing_Warehouse.ID";
            if (!string.IsNullOrWhiteSpace(Ssearch))
            {
                resule += " where FormCode like '%" + Ssearch + "%'";
            }
            return _baseRepository.ExecuteSqlCollection<V_IOWarehouse>(resule);
        }

        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="pager"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public PagedList<V_IOWarehouse> GetWarehousInfoService(ref PagerModel pager, LogOnUserModel user, SearchModel SearchModel)
        {
            StringBuilder strSql1 = new StringBuilder();
            strSql1.Append(" ");
            strSql1.Append("ID,");
            strSql1.Append("EnterpriseName,");
            strSql1.Append("FormCode,");
            strSql1.Append("ProductName,");
            strSql1.Append("ProductCode,");
            strSql1.Append("Location,");
            strSql1.Append("Status,");
            strSql1.Append("CreateLoginName,");
            strSql1.Append("Remark,");
            strSql1.Append("CreateDate,");
            strSql1.Append("Num,");
            strSql1.Append("WarehouseName,");
            strSql1.Append("WarehouseId,");
            strSql1.Append("FilePath,");
            var strSql = new StringBuilder(strSql1.ToString().Trim(','));
            pager.FldName = strSql.ToString();
            pager.TblName = " V_IOWarehouse ";
            if (user.Distributor != 0)//经销商
            {
                pager.StrCondition += string.Format(" and V_IOWarehouse.CreateLoginID in (select ID from sys_user where FIND_IN_SET(distributor,getDiscChild({0})))", user.Distributor);
            }
            else
            {
                if (user.EnterpriseId != 1)
                {
                    if (string.IsNullOrEmpty(user.JuniorEnterprise))
                        pager.StrCondition += " and (V_IOWarehouse.EnterpriseID  in (0))";
                    else
                        pager.StrCondition += " and (V_IOWarehouse.EnterpriseID in (" + user.JuniorEnterprise + "))";
                }


            }
            if (SearchModel != null)
            {
                if (!string.IsNullOrWhiteSpace(SearchModel.Key))
                {
                    var list = GetParentCode(SearchModel.Key);
                    if (list != null)
                    {
                        SearchModel.Key = list[0].Wl_Code;
                        pager.FldName+=",'"+ list[0].levv +"' as Levv ";
                    }

                    pager.StrCondition += string.Format(" and  (V_IOWarehouse.FormCode in(select DISTINCT formCode from antifleeing_warehousingdetails WHERE wlcode='{0}'))", SearchModel.Key);
                }
                if (!string.IsNullOrWhiteSpace(SearchModel.Code))
                {
                    var list = GetParentCode(SearchModel.Code);
                    if (list != null)
                    {
                        pager.FldName += ",'" + list[0].levv + "' as Levv ";
                        SearchModel.Code = list[0].Wl_Code;
                    }
                    pager.StrCondition += string.Format(" and  (V_IOWarehouse.FormCode in(select DISTINCT formCode from antifleeing_warehousingdetails WHERE wlcode='{0}'))", SearchModel.Code);
                }
                if (!string.IsNullOrWhiteSpace(SearchModel.ProductName))
                {
                    pager.StrCondition += " and (concat_ws('',V_IOWarehouse.ProductName) like '%" + SearchModel.ProductName + "%')";
                }
                if (!string.IsNullOrWhiteSpace(SearchModel.WarehouseName))
                {
                    pager.StrCondition += " and (concat_ws('',V_IOWarehouse.WarehouseName) like '%" + SearchModel.WarehouseName + "%')";
                }
                if (SearchModel.StartDate != "" && SearchModel.StartDate != null)
                {
                    pager.StrCondition += " and  (left(CreateDate,10) >= '" + SearchModel.StartDate + "')";
                }
                if (SearchModel.EndDate != "" && SearchModel.EndDate != null)
                {
                    pager.StrCondition += " and  (left(CreateDate,10) <= '" + SearchModel.EndDate + "')";
                }
            }
            pager.StrCondition += " and formtype=1 and ViewDel=0 ";
            if (string.IsNullOrEmpty(pager.FldSort))
                pager.FldSort = " ID desc";
            MySqlParameter[] parameters = _baseRepository.SqParameterRefactor(ref pager);
            IEnumerable<V_IOWarehouse> resultList = _baseRepository.ExecuteStoredProcedureCollection<V_IOWarehouse>("Common_PageList", parameters);
            return new PagedList<V_IOWarehouse>(resultList.ToList(), pager.Page, pager.PageSize, 1, Convert.ToInt32(parameters[6].Value));
        }

        /// <summary>
        /// 生成入库编码 机构ID前四位 加自增长的4位字符串
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string GetCode(string id)
        {
            string Code = GetEnterprise(id).Code;
            if (Code.Length < 4)//如果小于4 用0补充
            {
                for (int i = 0; i < 4 - Code.Length; i++)
                {
                    Code += "0";
                }
            }
            // else Code = Code.Substring(0, 4);
            AntiFleeing_IOWarehouse model = new AntiFleeing_IOWarehouse();
            //判断单据号是否存在
            if (Code.Length == 4)
            {
                model = GetIOWarehouse("RK" + Code);
            }
            else model = GetIOWarehouseBy2("RK" + Code);

            string str = "";
            if (model == null)//不存在 直接加1
            {
                return "RK" + Code + "0001";
            }
            else
            {

                str = model.FormCode.Substring(model.FormCode.Length - 4, 4);
                int num = int.Parse(str);
                num++;
                str = num.ToString();
                if (str.Length < 4)//如果小于4 用0补充
                {

                    str = str.PadLeft(4, '0');
                    //str= str.PadLeft(4-str.Length,'0');
                }
                else str = str.Substring(0, 4);

            }
            Code = "RK" + Code + str;
            return Code;
        }
        /// <summary>
        /// 根据机构id 获取机构
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public V_IOWarehouse GetCargoId(int id)
        {
            string sql = "SELECT*from V_IOWarehouse where id=" + id;
            var result = _baseRepository.ExecuteSqlCollection<V_IOWarehouse>(sql).FirstOrDefault();
            return result;
        }

        public Organization_Enterprise GetEnterprisebyCode(string code)
        {
            string sql = string.Format("select ID, Code, EnterpriseName, OrganizationForm, OrganizationId, SuperiorsOrganization, ProvinceId, City, Region, Address, StartTime, EndTime, PersonCharge, PersonMobile, LandlinePhone, JurisdictionRegion, Img, Remark, ViewDel, ViewFlag, ChangeLoginID, ChangeLoginName, ChangeDate, CreateDate from Organization_Enterprise where Code ={0}", code);
            return _baseRepository.ExecuteSqlCollection<Organization_Enterprise>(sql).FirstOrDefault();
        }
        public Organization_Enterprise GetEnterprise(string id)
        {
            string sql = string.Format("select ID, Code, EnterpriseName, OrganizationForm, OrganizationId, SuperiorsOrganization, ProvinceId, City, Region, Address, StartTime, EndTime, PersonCharge, PersonMobile, LandlinePhone, JurisdictionRegion, Img, Remark, ViewDel, ViewFlag, ChangeLoginID, ChangeLoginName, ChangeDate, CreateDate from Organization_Enterprise where id ={0}", id);
            return _baseRepository.ExecuteSqlCollection<Organization_Enterprise>(sql).FirstOrDefault();
        }
        /// <summary>
        /// 根据机构Id获取最高父级机构信息（诺标除外）
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Organization_Enterprise GetMaxEnterpriseIInfo(int id)
        {
            string sql = string.Format("select ID, Code, EnterpriseName, OrganizationForm, OrganizationId, SuperiorsOrganization, ProvinceId, City, Region, Address, StartTime, EndTime, PersonCharge, PersonMobile, LandlinePhone, JurisdictionRegion, Img, Remark, ViewDel, ViewFlag, ChangeLoginID, ChangeLoginName, ChangeDate, CreateDate from Organization_Enterprise where FIND_IN_SET(Id,getEnterpriseMaxParentId({0}))", id);
            return _baseRepository.ExecuteSqlCollection<Organization_Enterprise>(sql).FirstOrDefault();
        }
        /// <summary>
        /// 根据RK单号获取  入库实体
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public AntiFleeing_IOWarehouse GetIOWarehouse(string code)
        {
            string sql = string.Format(" select ID, EnterpriseID, FormCode, ScalingRelation, Num, FilePath, ProductID, `Explain`, Type, BrandId, WarehouseId, Location, Unit, `Status`, CreateLoginID, CreateLoginName, CreateDate, ChangeLoginID, ChangeLoginName, ChangeDate, ViewDel, Remark, SaleAreaId, Distributor, FormType  from AntiFleeing_IOWarehouse where ViewDel=0 and FormCode like '{0}%' order by CreateDate DESC ", code);
            return _baseRepository.ExecuteSqlCollection<AntiFleeing_IOWarehouse>(sql).FirstOrDefault();
        }
        public AntiFleeing_IOWarehouse GetIOWarehouseBy2(string code)
        {
            string sql = string.Format(" select ID, EnterpriseID, FormCode, ScalingRelation, Num, FilePath, ProductID, `Explain`, Type, BrandId, WarehouseId, Location, Unit, `Status`, CreateLoginID, CreateLoginName, CreateDate, ChangeLoginID, ChangeLoginName, ChangeDate, ViewDel, Remark, SaleAreaId, Distributor, FormType  from AntiFleeing_IOWarehouse where ViewDel=0 and FormCode like '{0}____' order by CreateDate DESC ", code);
            return _baseRepository.ExecuteSqlCollection<AntiFleeing_IOWarehouse>(sql).FirstOrDefault();
        }
        
        /// <summary>
        /// 添加入库记录
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Add(AntiFleeing_IOWarehouse model)
        {
            return _baseRepository.InsertReturnID<AntiFleeing_IOWarehouse>(model);
        }
       
        /// <summary>
        /// 获取所有的仓库
        /// </summary>
        public List<AntiFleeing_Warehouse> GetWarehouseService(string enterIds, int warehouseId, int _warehouseId)
        {
            string sql = "select ID, WarehouseName from AntiFleeing_Warehouse where  ViewDel=0 and ChangeLoginID in(select ID from sys_user where Distributor=0 and EnterpriseId in ({0})) and id!={1}";
            if (enterIds != " getJuniorEnterprise(1)")
            {
                sql = string.Format(sql, enterIds, warehouseId);
            }
            else sql = string.Format(sql, 1, warehouseId);//管理员
            if (_warehouseId != 0)
            {
                sql += string.Format(" or Id={0}", _warehouseId);
            }
            return _baseRepository.ExecuteSqlCollection<AntiFleeing_Warehouse>(sql).ToList();
        }

        public List<AntiFleeing_Warehouse> GetWarehouseService(int userId, int warehouseId = 0, int _warehouseId = 0)
        {
            string sql = "select ID,WarehouseName from AntiFleeing_Warehouse where ViewDel=0 and ChangeLoginID=@CreateLoginID and Id!=@ID ";
            if (_warehouseId != 0)
            {
                sql += string.Format(" or Id={0}", _warehouseId);
            }
            MySqlParameter[] parameters = {
                                            new MySqlParameter("@CreateLoginID",userId),
                                             new MySqlParameter("@ID",warehouseId),
                                        };
            return _baseRepository.ExecuteSqlCollection<AntiFleeing_Warehouse>(sql, parameters).ToList();
        }
        //更新实体
        public int EditStorageServices(AntiFleeing_IOWarehouse IOWarehouse)
        {
            return _baseRepository.Update<AntiFleeing_IOWarehouse>(IOWarehouse);
        }
        #endregion

        #region 分离单标
        public int InputImport(string strSql)
        {
            string sql = @"  insert into AntiFleeing_WareHousingDetails(WLcode,FormCode,UserID,WarehouseId,CreateDate,ChangeDate) values" + strSql;
            return _baseRepository.ExecuteSqlReturnID<int>(sql);
        }
        public int OutImport(string strSql)
        {
            string sql = @"  insert into AntiFleeing_OutboundDetails(WLcode,FormCode,DistributorID,CreateDate,ChangeDate) values" + strSql;
            return _baseRepository.ExecuteSqlReturnID<int>(sql);
        }

        //分离单标批量插入各种操作记录
        public int AddRecords(string pcode, string code)
        {
            string sql = @"-- 调拨
insert into antifleeing_allocationdetails(WLcode,FormCode,createDate,CreateLoginID,CreateLoginName) 
(select '{0}' as WLcode,FormCode,createDate,CreateLoginID,CreateLoginName  from antifleeing_allocationdetails where WLcode='{1}'  );

-- 出库
insert into antifleeing_outbounddetails(WLcode,formCode,distributorId,createDate,changeDate)
(select '{0}' as WLcode,formCode,distributorId,createDate,changeDate from antifleeing_outbounddetails where WLcode='{1}' );

-- 退货
insert into antifleeing_returndetails(WLcode ,FormCode,createDate,CreateLoginID)
(select '{0}' as WLcode ,FormCode,createDate,CreateLoginID from antifleeing_returndetails where WLcode='{1}' );

-- 调货
insert into antifleeing_transdetails (WLcode ,FormCode,createDate,CreateLoginID)
(select '{0}' as WLcode ,FormCode,createDate,CreateLoginID from antifleeing_transdetails where WLcode='{1}');

-- 入库
insert into antifleeing_warehousingdetails(WLcode ,FormCode,UserID,WarehouseId ,createDate,changedate)
(select '{0}' as WLcode ,FormCode,UserID,WarehouseId ,createDate,changedate from antifleeing_warehousingdetails where WLcode='{1}');
";
            sql = string.Format(sql, code, pcode);

            return _baseRepository.ExecuteSql<int>(sql);
        }
        /// <summary>
        /// 修改父级Code
        /// </summary>
        /// <param name="fw_code"></param>
        /// <param name="ParentCode"></param>
        /// <param name="TableName"></param>
        /// <returns></returns>
        public int UpdateParentCode(string wlCode, string ParentCode)
        {
            string tableName = "nbcodemain.AntiFake_Digitcode" + wlCode.Substring(0, AppConst.SubStrLen);
            string sql = @"update {0} set ParentCode={1} where Wl_Code='{2}' ";
            sql = string.Format(sql, tableName, ParentCode, wlCode);
            return _baseRepository.ExecuteSql<int>(sql); ;
        }
        #endregion

        #region 列出整箱
        /// <summary>
        /// 列出整箱
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="WlCode"></param>
        /// <returns></returns>
        public List<V_ListBox> ListGetTable(string WlCode)
        {
           //判断表存不存在
            if (WlCode.Length < 16) return null;
            string sql = string.Format("SELECT COUNT(1) FROM information_schema.tables WHERE table_schema='{0}' AND table_name = 'AntiFake_Digitcode{1}'", "nbcodemain", WlCode.Substring(0, AppConst.SubStrLen));
            int i=int.Parse(_baseRepository.ExecuteText<string>(sql));
            if (i > 0)
            {
                string tableName = "nbcodemain.AntiFake_Digitcode" + WlCode.Substring(0, AppConst.SubStrLen);
                MySqlParameter[] parameters = {
                                            new MySqlParameter("@tablename",tableName),
                                            new MySqlParameter("@WlCode",WlCode),
                                        };
                return _baseRepository.ExecuteStoredProcedureCollection<V_ListBox>("Proc_GetCodeList", parameters).ToList();
            }
            else return null; 
             
        }
        public List<V_ListBox> GetParentCode(string WlCode)
        {
            //判断表存不存在
            if (WlCode.Length < 10) return null;
            string sql = string.Format("SELECT COUNT(1) FROM information_schema.tables WHERE table_schema='{0}' AND table_name = 'AntiFake_Digitcode{1}'", "nbcodemain", WlCode.Substring(0, AppConst.SubStrLen));
            int i = int.Parse(_baseRepository.ExecuteText<string>(sql));
            if (i > 0)
            {
                string tableName = "nbcodemain.AntiFake_Digitcode" + WlCode.Substring(0, AppConst.SubStrLen);
                MySqlParameter[] parameters = {
                                            new MySqlParameter("@tablename",tableName),
                                            new MySqlParameter("@WlCode",WlCode),
                                        };
                return _baseRepository.ExecuteStoredProcedureCollection<V_ListBox>("proc_getCodeParList", parameters).ToList();
            }
            else return null;

        }
        #endregion

        #region 物流库存统计
        public int SearchChildrenCount(string WlCode)
        {
            int count = 0;
            MySqlParameter[] parameters = {
                                            new MySqlParameter("@WlCode",WlCode),  
                                             new MySqlParameter("@Count",count), 
                                        };
            parameters[1].Direction = ParameterDirection.Output;
            var _connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["mgj_basemysql"].ConnectionString;
            using (MySqlConnection conn = new MySqlConnection(_connectionString))
            {
                using (MySqlCommand cmd = conn.CreateCommand())
                {
                    conn.Open();
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "Proc_GetChildrenCount";

                    foreach (MySqlParameter item in parameters)
                    {
                        cmd.Parameters.Add(item);
                    }
                    var _Result = cmd.ExecuteNonQueryAsync();
                    if (_Result.IsFaulted)
                    {
                        count = 1;
                    }
                    else
                    {
                        var value = parameters[1].Value ?? "1";
                        count = (int)value;
                    }
                }
            }
            return count;
        }
        public PagedList<StatisticModel> GetCountDataByProduct(ref PagerModel pager, string SearchKey, int warehouseid)
        {
            pager.FldName = "*";
            string sql = @"
     select 
    b.productid,
    b.EnterpriseID,
    b.CreateLoginID,
    g.productname,
    b.createDate,
    m.EnterpriseName,
    WarehouseName,
    sum(case b.formtype when 1 then b.dragnum else 0 end) inwarehouse,
    sum(case b.formtype when 2 then b.dragnum else 0 end) outwarehouse,
    (select sum(c.dragnum) from antifleeing_productreturn c where c.checkstatus = 3 and c.gowarehouseid = b.warehouseid and c.`status` = 2 and  c.productid = b.productid) productreturn,
    (select sum(e.dragnum) from antifleeing_allocation e where e.`status` = 2 and e.viewdel = 0 and e.fromwarehouseid = b.warehouseid and e.productid = b.productid) outallot,
    (select sum(f.dragnum) from antifleeing_allocation f where f.`status` = 2 and f.viewdel = 0 and f.gowarehouseid = b.warehouseid and f.productid = b.productid) inallot
    from antifleeing_iowarehouse b 
    left join product_product g on g.id = b.productid 
    LEFT JOIN antifleeing_warehouse w on b.warehouseid=w.ID
    LEFT JOIN organization_enterprise m on b.EnterpriseID=m.ID 
  -- where warehouseid ={0}  group by productid     
  ";
            if (warehouseid != 0 && string.IsNullOrWhiteSpace(SearchKey))
            {
                sql += string.Format(" where warehouseid ={0}  group by productid ", warehouseid);
            }
            else if (warehouseid == 0 && !string.IsNullOrWhiteSpace(SearchKey))
            {
                sql += string.Format(" where g.productname like '%{0}%' group by b.WarehouseId ", SearchKey);
                // pager.StrCondition += " and  w.productname like '%" + SearchKey + "%' ";
            }
            else if (warehouseid != 0 && !string.IsNullOrWhiteSpace(SearchKey))
            {
                sql += string.Format(" where warehouseid ={0}  and  g.productname like '%{1}%'   ", warehouseid, SearchKey);
            }
            else
            {
                return new PagedList<StatisticModel>();
            }
            pager.TblName = string.Format("( {0})w", sql);
            MySqlParameter[] parameters = _baseRepository.SqParameterRefactor(ref pager);
            IEnumerable<StatisticModel> resultList = _baseRepository.ExecuteStoredProcedureCollection<StatisticModel>("Common_PageList", parameters);
            return new PagedList<StatisticModel>(resultList.ToList(), pager.Page, pager.PageSize, 1, Convert.ToInt32(parameters[6].Value));
        }
        #endregion

        #region 防窜货统计
        public PagedList<Antifleeing_PreventFlee> GetFleeGoodsDataServices(ref PagerModel pager, string SearchKey, string code)
        {

            pager.FldName = "*";
            string sql = @"(
   select o.EnterpriseName,a.Fw_Code,c.ProductName,a.QueryIp,a.Address,a.QueryType,a.QueryTime,d.`Name` as DisName,e.`Name` as SalesAreaName,d.JurisdictionPrivanceName,d.JurisdictionCityName,d.JurisdictionRegionName
,d.IsCrossArea,d.AcrossPrivanceName,d.AcrossCityName,d.AcrossRegionName from nblogmain.`codelog" + code + "`  a " +
" left join antifleeing_outbounddetails b on a.Fw_Code=b.WLcode " +
" left join product_product c on a.ProductId=c.ID " +
" left join antifleeing_distributor d on b.DistributorID=d.ID " +
" left join antifleeing_salesarea e on d.SalesAreaID=e.ID " +
"LEFT JOIN organization_enterprise o on a.EnterpriseId=o.ID) w ";
            if (!string.IsNullOrWhiteSpace(SearchKey))
            {
                pager.StrCondition += " and  w.Fw_Code like '%" + SearchKey + "%' ";
            }

            pager.TblName = string.Format(sql);
            MySqlParameter[] parameters = _baseRepository.SqParameterRefactor(ref pager);
            IEnumerable<Antifleeing_PreventFlee> resultList = _baseRepository.ExecuteStoredProcedureCollection<Antifleeing_PreventFlee>("Common_PageList", parameters);
            foreach (var item in resultList)
            {
                if (!string.IsNullOrEmpty(item.Address))
                {

                    var adds = item.Address.Split(',');
                    var province = adds.Length > 0 ? adds[0] : "";
                    var city = adds.Length > 1 ? adds[1] : "";
                    var region = adds.Length > 2 ? adds[2] : "";
                    if (item.JurisdictionRegionName.IndexOf(region) < 0 && item.JurisdictionCityName.IndexOf(city) < 0 && item.JurisdictionPrivanceName.IndexOf(province) < 0)
                    {//窜货
                        if (item.IsCrossArea != 0)
                        {
                            if (item.AcrossRegionName.IndexOf(region) < 0 && item.AcrossCityName.IndexOf(city) < 0 && item.AcrossPrivanceName.IndexOf(province) < 0)
                                item.IsAntifleeing = "窜货";
                            else item.IsAntifleeing = "正常";
                        }
                        else item.IsAntifleeing = "窜货";
                    }
                    else item.IsAntifleeing = "正常";

                }
                else item.IsAntifleeing = "不明确";

            }
            return new PagedList<Antifleeing_PreventFlee>(resultList.ToList(), pager.Page, pager.PageSize, 1, Convert.ToInt32(parameters[6].Value));
        }
        #endregion
    }
}
